﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PrimeFactorLibrary;

namespace PrimeFactorApp
{
    class Program
    {
        static void Main(string[] args)
        {
            PrimeFactorCalculator calculator = new PrimeFactorCalculator();
            Console.WriteLine("质因数分解器");
            Console.WriteLine("----------------");

            while (true)
            {
                Console.Write("请输入一个1到1000之间的正整数（或输入 'exit' 退出）：");
                string input = Console.ReadLine();

                if (input.Trim().ToLower() == "exit")
                {
                    break;
                }

                if (int.TryParse(input, out int number))
                {
                    try
                    {
                        string factors = calculator.PrimeFactors(number);
                        Console.WriteLine($"{number} 的质因数分解为：{factors}");
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine($"错误：{ex.Message}");
                    }
                }
                else
                {
                    Console.WriteLine("输入无效，请输入一个整数。");
                }

                Console.WriteLine();
            }

            Console.WriteLine("感谢使用质因数分解器。按任意键退出...");
            Console.ReadKey();
        }
    }
}

